using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class FindControlMethodPage : System.Web.UI.Page
{
    SqlDataSource sqlDataSource;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            FillData(GridView1);
    }

    void FillData(GridView gridView)
    {
        sqlDataSource = new SqlDataSource();
        sqlDataSource.ConnectionString =
        WebConfigurationManager.ConnectionStrings[
            "RecruitVietnamDbConnectionString"
            ].ConnectionString;
        sqlDataSource.SelectCommandType =
        SqlDataSourceCommandType.Text;
        sqlDataSource.SelectCommand = "select top 5 " +
        "RecruiterID,Email,CompanyName, "
        + "ContactName,Address from tblRCAccounts";
        gridView.DataSource = sqlDataSource;
        gridView.DataBind();

    }




     
    string ShowValue(GridView gridView)
    {
        string result="";
        foreach(GridViewRow gridViewRow in gridView.Rows)
         {
             TextBox textBox = 
             (TextBox)gridViewRow.FindControl("txtAmount");
             
             if(textBox.Text!="")
             {
                 result += gridViewRow.Cells[1].Text 
                 + ": " + textBox.Text +"<br>";
             }
         }
         return result;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
       this.Literal1.Text= ShowValue(this.GridView1);
    }
}
